// var i;
// var $eventManager = require("./EventManager");
// var $resKeeper = require("./ResKeeper");
// var $evenType = require("./EvenType");
// var $guideControl = require("./GuideControl");
// var d = cc._decorator;
// var p = d.ccclass;
// var h = d.property;
// var f = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.shouNode = null;
//         t.quanNode = null;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.StartSet = function (e) {
//         var t = this;
//         this.shouNode.stopAllActions();
//         this.shouNode.children[0].active = !0;
//         this.shouNode.children[1].active = !1;
//         this.quanNode.stopAllActions();
//         this.quanNode.active = !1;
//         if (e) {
//             this.quanNode.active = !0;
//             this.quanNode.runAction(
//                 cc.repeatForever(
//                     cc.sequence(
//                         cc.callFunc(function () {
//                             t.quanNode.opacity = 255;
//                             t.quanNode.scale = 1;
//                         }),
//                         cc.spawn(cc.scaleTo(0.5, 1.5, 1.5), cc.fadeOut(1))
//                     )
//                 )
//             );
//             this.shouNode.runAction(
//                 cc.repeatForever(
//                     cc.sequence(
//                         cc.delayTime(0.5),
//                         cc.callFunc(function () {
//                             t.shouNode.children[0].active = !t.shouNode.children[0].active;
//                             t.shouNode.children[1].active = !t.shouNode.children[0].active;
//                         })
//                     )
//                 )
//             );
//         }
//     };
//     t.prototype.onEnable = function () {
//         $eventManager.EventMgr.addEventListener($evenType.EVENT_TYPE.HideGuideShow, this.CloseThis, this);
//     };
//     t.prototype.onDisable = function () {
//         $eventManager.EventMgr.rmEventListener($evenType.EVENT_TYPE.HideGuideShow, this.CloseThis, this);
//     };
//     t.prototype.CloseThis = function () {
//         $guideControl.GuideCtrl.RecycleOneShou(this.node);
//     };
//     __decorate([h(cc.Node)], t.prototype, "shouNode", void 0);
//     __decorate([h(cc.Node)], t.prototype, "quanNode", void 0);
//     return __decorate([p], t);
// })($resKeeper.default);
// exports.default = f;

import { EventMgrInstance } from "./EventManager";
import ResKeeper from "./ResKeeper";
import { EVENT_TYPE } from "./EvenType";
import { GuideCtrlInstance } from "./GuideControl";
const { ccclass, property } = cc._decorator;

/**
 * 建议类名: GuideNodeHandler
 * 引导手势类，用于管理引导手势节点
 */
@ccclass
class GuideShou extends ResKeeper {
    @property(cc.Node)
    public shouNode: cc.Node = null; // 手势节点

    @property(cc.Node)
    public quanNode: cc.Node = null; // 圈圈节点

    constructor() {
        super();
    }

    /**
     * 建议方法名: initializeSettings
     * 初始化设置
     * @param isActive 是否激活
     */
    public initializeSettings(isActive: boolean): void {
        // 停止所有动作，并设置初始状态
        this.shouNode.stopAllActions();
        this.shouNode.children[0].active = true;
        this.shouNode.children[1].active = false;
        this.quanNode.stopAllActions();
        this.quanNode.active = false;

        if (isActive) {
            this.quanNode.active = true;
            this.quanNode.runAction(
                cc.repeatForever(
                    cc.sequence(
                        cc.callFunc(() => {
                            this.quanNode.opacity = 255;
                            this.quanNode.scale = 1;
                        }),
                        cc.spawn(
                            cc.scaleTo(0.5, 1.5, 1.5),
                            cc.fadeOut(1)
                        )
                    )
                )
            );
            this.shouNode.runAction(
                cc.repeatForever(
                    cc.sequence(
                        cc.delayTime(0.5),
                        cc.callFunc(() => {
                            let child_0 = this.shouNode.children[0];
                            let child_1 = this.shouNode.children[1];
                            child_0.active = !child_0.active;
                            child_1.active = !child_0.active;
                        })
                    )
                )
            );
        }
    }

    /**
     * 建议方法名: onComponentEnable
     * 组件启用时的回调
     */
    public onEnable(): void {
        EventMgrInstance.addListener(EVENT_TYPE.HideGuideShow, this.closeComponent, this);
    }

    /**
     * 建议方法名: onComponentDisable
     * 组件禁用时的回调
     */
    public onDisable(): void {
        EventMgrInstance.removeListener(EVENT_TYPE.HideGuideShow, this.closeComponent, this);
    }

    /**
     * 建议方法名: closeComponent
     * 关闭当前组件
     */
    public closeComponent(): void {
        GuideCtrlInstance.recycleOneFingerGuide(this.node);
    }
}

export default GuideShou;